public class HuffmanTree {
	// 哈夫曼树
	public static int huffmanTree(int[] arr){
		PriorityQueue<Integer> queue = new PriorityQueue<>();
		for(int i = 0; i < arr.length; i++){
			queue.add(arr[i]);
		}
		int cur = 0;
		int sum = 0;
		while(queue.size() > 1){
			cur = queue.poll() + queue.poll();
			sum += cur;
			queue.add(cur);
		}
		return sum;
	}
}